package com.barbeque.mall.service.wx;

import com.barbeque.mall.bean.user.MarketUser;
import com.barbeque.mall.bean.wx.feedback.WxMarketFeedback;
import com.barbeque.mall.mapper.MarketFeedbackMapper;
import com.barbeque.mall.mapper.WxMarketFeedbackMapper;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author bai
 * @since 2022/07/20 22:36
 */
@Service
public class WxFeedBackServiceImpl implements WxFeedBackService {
    @Autowired
    MarketFeedbackMapper MarketFeedbackMapper;
    @Autowired
    WxMarketFeedbackMapper wxMarketFeedbackMapper;

    /**
     * 提交反馈信息的逻辑
     * @param
     */
    @Override
    public void insertFeedBackInfo(WxMarketFeedback wxMarketFeedback) {
        MarketUser primaryPrincipal = (MarketUser) SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
        Integer userId = primaryPrincipal.getId();
        String username = primaryPrincipal.getUsername();


        wxMarketFeedback.setUserId(userId);
        wxMarketFeedback.setUsername(username);

        Date date = new Date();
        wxMarketFeedback.setAddTime(date);
        wxMarketFeedback.setUpdateTime(date);

        wxMarketFeedbackMapper.insertSelective(wxMarketFeedback);
    }
}
